using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;

using PickGold.Charting.Utilities;
using PickGold.Charting.Design;

namespace PickGold.Charting
{
	[SRDescription("DescriptionAttributeAnnotationGroup_AnnotationGroup"), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public class AnnotationGroup : Annotation
	{
		internal AnnotationCollection annotations;

		public AnnotationGroup()
		{
			this.annotations = new AnnotationCollection(this);
			this.annotations.AnnotationGroup = this;
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && (this.annotations != null))
			{
				this.annotations.Dispose();
				this.annotations = null;
			}
			base.Dispose(disposing);
		}

		internal override void Paint(Chart chart, ChartGraphics graphics)
		{
			foreach (Annotation annotation in this.annotations)
			{
				annotation.Paint(chart, graphics);
			}
			if ((base.Common.ProcessModePaint && this.IsSelected) || base.Common.ProcessModeRegions)
			{
				PointF empty = PointF.Empty;
				PointF anchorLocation = PointF.Empty;
				SizeF size = SizeF.Empty;
				this.GetRelativePosition(out empty, out size, out anchorLocation);
				PointF tf3 = new PointF(empty.X + size.Width, empty.Y + size.Height);
				RectangleF rectArea = new RectangleF(empty, new SizeF(tf3.X - empty.X, tf3.Y - empty.Y));
				if (rectArea.Width < 0f)
				{
					rectArea.X = rectArea.Right;
					rectArea.Width = -rectArea.Width;
				}
				if (rectArea.Height < 0f)
				{
					rectArea.Y = rectArea.Bottom;
					rectArea.Height = -rectArea.Height;
				}
				if ((!rectArea.IsEmpty && !float.IsNaN(rectArea.X)) && ((!float.IsNaN(rectArea.Y) && !float.IsNaN(rectArea.Right)) && !float.IsNaN(rectArea.Bottom)))
				{
					if (base.Common.ProcessModeRegions)
					{
						base.Common.HotRegionsList.AddHotRegion(rectArea, base.ReplaceKeywords(this.ToolTip), base.ReplaceKeywords(this.Url), base.ReplaceKeywords(this.MapAreaAttributes), base.ReplaceKeywords(base.PostBackValue), this, ChartElementType.Annotation, string.Empty);
					}
					this.PaintSelectionHandles(graphics, rectArea, null);
				}
			}
		}

		[DefaultValue(typeof(ContentAlignment), "MiddleCenter"), SRDescription("DescriptionAttributeAlignment"), Browsable(false), SRCategory("CategoryAttributeAppearance")]
		public override ContentAlignment Alignment
		{
			get
			{
				return base.Alignment;
			}
			set
			{
				base.Alignment = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.Alignment = value;
				}
			}
		}

		[SRCategory("CategoryAttributeAnnotations"), PersistenceMode(PersistenceMode.InnerProperty), SRDescription("DescriptionAttributeAnnotationGroup_Annotations"), Editor(typeof(AnnotationCollectionEditor), typeof(UITypeEditor))]
		public AnnotationCollection Annotations
		{
			get
			{
				return this.annotations;
			}
		}

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), SRDescription("DescriptionAttributeAnnotationType"), SerializationVisibility(SerializationVisibility.Hidden), SRCategory("CategoryAttributeMisc"), Bindable(true), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
		public override string AnnotationType
		{
			get
			{
				return "Group";
			}
		}

		[SRCategory("CategoryAttributeAppearance"), DefaultValue(typeof(Color), ""), SRDescription("DescriptionAttributeBackColor"), Browsable(false), NotifyParentProperty(true), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public override Color BackColor
		{
			get
			{
				return base.BackColor;
			}
			set
			{
				base.BackColor = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.BackColor = value;
				}
			}
		}

		[DefaultValue(0), SRCategory("CategoryAttributeAppearance"), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackGradientStyle"), Editor(typeof(GradientEditor), typeof(UITypeEditor)), Browsable(false)]
		public override GradientStyle BackGradientStyle
		{
			get
			{
				return base.BackGradientStyle;
			}
			set
			{
				base.BackGradientStyle = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.BackGradientStyle = value;
				}
			}
		}

		[SRDescription("DescriptionAttributeBackHatchStyle"), Editor(typeof(HatchStyleEditor), typeof(UITypeEditor)), Browsable(false), DefaultValue(0), NotifyParentProperty(true), SRCategory("CategoryAttributeAppearance")]
		public override ChartHatchStyle BackHatchStyle
		{
			get
			{
				return base.BackHatchStyle;
			}
			set
			{
				base.BackHatchStyle = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.BackHatchStyle = value;
				}
			}
		}

		[DefaultValue(typeof(Color), ""), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), Browsable(false), SRCategory("CategoryAttributeAppearance"), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackSecondaryColor")]
		public override Color BackSecondaryColor
		{
			get
			{
				return base.BackSecondaryColor;
			}
			set
			{
				base.BackSecondaryColor = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.BackSecondaryColor = value;
				}
			}
		}

		[SRDescription("DescriptionAttributeAnnotationGroup_ClipToChartArea"), DefaultValue("NotSet"), Browsable(false), SRCategory("CategoryAttributeMisc"), TypeConverter(typeof(LegendAreaNameConverter))]
		public override string ClipToChartArea
		{
			get
			{
				return base.ClipToChartArea;
			}
			set
			{
				base.ClipToChartArea = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.ClipToChartArea = value;
				}
			}
		}

		[SRDescription("DescriptionAttributeTextFont"), Browsable(false), SRCategory("CategoryAttributeAppearance"), DefaultValue(typeof(System.Drawing.Font), "Microsoft Sans Serif, 8pt")]
		public override System.Drawing.Font Font
		{
			get
			{
				return base.Font;
			}
			set
			{
				base.Font = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.Font = value;
				}
			}
		}

		[TypeConverter(typeof(ColorConverter)), SRDescription("DescriptionAttributeForeColor"), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), Browsable(false), SRCategory("CategoryAttributeAppearance"), DefaultValue(typeof(Color), "Black")]
		public override Color ForeColor
		{
			get
			{
				return base.ForeColor;
			}
			set
			{
				base.ForeColor = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.ForeColor = value;
				}
			}
		}

		[SRCategory("CategoryAttributeAppearance"), Browsable(false), SRDescription("DescriptionAttributeAnnotationGroup_Selected"), DefaultValue(false)]
		public override bool IsSelected
		{
			get
			{
				return base.IsSelected;
			}
			set
			{
				base.IsSelected = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.IsSelected = false;
				}
			}
		}

		[SRDescription("DescriptionAttributeAnnotationGroup_SizeAlwaysRelative"), SRCategory("CategoryAttributePosition"), DefaultValue(true)]
		public override bool IsSizeAlwaysRelative
		{
			get
			{
				return base.IsSizeAlwaysRelative;
			}
			set
			{
				base.IsSizeAlwaysRelative = value;
			}
		}

		[Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(ColorConverter)), SRCategory("CategoryAttributeAppearance"), Browsable(false), DefaultValue(typeof(Color), "Black"), SRDescription("DescriptionAttributeLineColor")]
		public override Color LineColor
		{
			get
			{
				return base.LineColor;
			}
			set
			{
				base.LineColor = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.LineColor = value;
				}
			}
		}

		[SRCategory("CategoryAttributeAppearance"), DefaultValue(5), SRDescription("DescriptionAttributeLineDashStyle"), Browsable(false)]
		public override ChartDashStyle LineDashStyle
		{
			get
			{
				return base.LineDashStyle;
			}
			set
			{
				base.LineDashStyle = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.LineDashStyle = value;
				}
			}
		}

		[SRDescription("DescriptionAttributeLineWidth"), DefaultValue(1), SRCategory("CategoryAttributeAppearance"), Browsable(false)]
		public override int LineWidth
		{
			get
			{
				return base.LineWidth;
			}
			set
			{
				base.LineWidth = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.LineWidth = value;
				}
			}
		}

		[SRDescription("DescriptionAttributeSelectionPointsStyle")]
		[SRCategory("CategoryAttributeAppearance")]
		[DefaultValue(1)]
		[ParenthesizePropertyName(true)]
		[Browsable(false)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[SerializationVisibility(SerializationVisibility.Hidden)]
		internal override SelectionPointsStyle SelectionPointsStyle
		{
			get
			{
				return SelectionPointsStyle.Rectangle;
			}
		}

		[DefaultValue(typeof(Color), "128,0,0,0"), SRCategory("CategoryAttributeAppearance"), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), SRDescription("DescriptionAttributeShadowColor"), TypeConverter(typeof(ColorConverter)), Browsable(false)]
		public override Color ShadowColor
		{
			get
			{
				return base.ShadowColor;
			}
			set
			{
				base.ShadowColor = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.ShadowColor = value;
				}
			}
		}

		[Browsable(false), SRCategory("CategoryAttributeAppearance"), DefaultValue(0), SRDescription("DescriptionAttributeShadowOffset")]
		public override int ShadowOffset
		{
			get
			{
				return base.ShadowOffset;
			}
			set
			{
				base.ShadowOffset = value;
				foreach (Annotation annotation in this.annotations)
				{
					annotation.ShadowOffset = value;
				}
			}
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		[Browsable(false)]
		public override TextStyle TextStyle
		{
			get
			{
				return base.TextStyle;
			}
			set
			{
				base.TextStyle = value;
			}
		}

		[ParenthesizePropertyName(true)]
		[SRDescription("DescriptionAttributeAnnotationGroup_Visible")]
		[SRCategory("CategoryAttributeAppearance")]
		[DefaultValue(true)]
		public override bool Visible
		{
			get
			{
				return base.Visible;
			}
			set
			{
				base.Visible = value;
			}
		}
	}
}

